#pragma once
#include "../Mainloop/ProcessManager.h"
class HumanView : public IGameView
{
	friend class GameCodeApp;

protected:
	GameViewId m_ViewId;
	ActorId m_ActorId;

	ProcessManager* m_pProcessManager;				
	
	
	DWORD m_currTick;		
	DWORD m_lastDraw;		
	bool m_runFullSpeed;	


	virtual void VRenderText() {};

public:
	
	virtual void VPushElement(shared_ptr<IScreenElement> pElement);
	virtual void VRemoveElement(shared_ptr<IScreenElement> pElement);

	virtual void VOnRestore();
	virtual void VOnLostDevice();
	virtual void VOnRender(double fTime, float fElapsedTime);
	virtual GameViewType VGetType() const {return GameView_Human;}
	virtual GameViewId VGetId() const {return m_ViewId;}
	virtual void VOnAttach(GameViewId vid, ActorId aid)
	{
		m_ViewId = vid;
		m_ActorId = aid;
	}
	virtual void VOnUpdate(const int deltaMilliseconds);
	virtual LRESULT CALLBACK VOnMsgProc(AppMsg msg);
	HumanView(shared_ptr<IRenderer> renderer);
	virtual ~HumanView();

	shared_ptr<IPointerHandler> m_PointerHandler;
	shared_ptr<IKeyboardHandler> m_KeyboardHandler;
	ProcessManager* GetProcessManager() {return m_pProcessManager;}

	ScreenElementList m_ScreenElements;
class Console
	{
	public:
		Console(void);

		~Console(void);

		void AddDisplayText( const std::string & newText );
		void SetDisplayText( const std::string & newText );

		void SetActive( const bool bIsActive )  { m_bActive = bIsActive; }
		bool IsActive(void) const  { return m_bActive; }

		void HandleKeyboardInput( const unsigned int keyVal, const unsigned int oemKeyVal, const bool bKeyDown );

		void Update( const int deltaMilliseconds );

		void Render( );

	private:
		bool m_bActive;

		std::queue<std::string> m_DisplayStrings;

		RECT m_ConsoleOutputRect;	//Where results get shown
		RECT m_ConsoleInputRect;	//Where input is entered

		Color m_InputColor;
		Color m_OutputColor;

		std::string m_CurrentOutputString;	//What's the current output string?
		std::string m_CurrentInputString;	//What's the current input string?

		int m_ConsoleInputSize;	//Height of the input console window

		int m_CursorBlinkTimer;	//Countdown to toggle cursor blink state
		bool m_bCursorOn;	//Is the cursor currently displayed?

		bool m_bShiftDown;	//Is the shift button down?
		bool m_bCapsLockDown;	//Is the caps lock button down?

		//If this is true, we have a string to execute on our next update cycle.  
		//We have to do this because otherwise the user could interrupt in the midst
		//of an ::Update() call in another system.  This causes problems.
		bool m_bExecuteStringOnUpdate;
	};

	Console & GetConsole( void )
	{
		return m_Console;
	}

protected:
	Console m_Console;
};
